package com.company.behavioral.iterator_pattern.aggregat;

import com.company.behavioral.iterator_pattern.iterator.AbstractIterator;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName AbstractObjectList
 * @Author tiezheng.han
 * @Date 2020/9/4 16:00
 **/
public abstract class AbstractObjectList {
    protected List<Object> objects = new ArrayList<>();

    public AbstractObjectList(List<Object> objects) {
        this.objects = objects;
    }

    public void addObject(Object obj){
        this.objects.add(obj);
    }

    public void removeObject(Object obj){
        this.objects.remove(obj);
    }

    public List<Object> getObjects(){
        return this.objects;
    }

    /**
     * 声明创建迭代器对象的抽象方法
     */
    public abstract AbstractIterator createIterator();
}
